import myPromise from "./index.js"

/**resolve函数 */
export interface Resolve<T> {
    (data?: T): void
}
/**reject函数 */
export interface Reject {
    (error?: any): void
}
/**then的成功回调 */
export type FulfilledFn<T> = (res: T) => any
/**then的拒绝回调 */
export type RejectedFn = (err: any) => any
/**then函数 */
export type Then<T> = (onFulfilled?: FulfilledFn<T>, onRejected?: RejectedFn) => myPromise<T> | PromiseLike<T>
/**基础函数 */
export type Fn = () => void

/**类promise对象，必须包含then函数的一个对象 */
export interface PromiseLike<T> {
    then: (onFulfilled?: FulfilledFn<T>, onRejected?: RejectedFn) => any
}

/**promise的三种状态 */
export const enum Status {
    /**等待态 */
    Pending = 'Pending',
    /**完成态 */
    Fulfilled = 'Fulfilled',
    /**拒绝态 */
    Rejected = 'Rejected',
}